package cn.bonoon.controllers.account;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.bonoon.core.plugins.AccountService;
import cn.bonoon.entities.plugins.AccountEntity;
import cn.bonoon.kernel.web.ButtonEventType;
import cn.bonoon.kernel.web.annotations.grid.GridStandardDefinition;
import cn.bonoon.kernel.web.controllers.AbstractGridController;

@Controller
@RequestMapping("s/sys/account")
public class AccountController extends AbstractGridController<AccountEntity, AccountItem> {
	private final AccountService service;
	
	@Autowired
	public AccountController(AccountService service) {
		super(service);
		this.service = service;
	}

	@Override
	@GridStandardDefinition(
			insertClass = AccountInsert.class, 
			updateClass = AccountUpdate.class, 
			detailClass = AccountDetail.class)
	protected AccountService initLayoutGrid(LayoutGridRegister register) throws Exception {
		//添加按键
//		DialogInsertHandler.toolbar(register, service, AccountInsert.class);
//		OperateIdsHandler.resume(register, service);
//		OperateIdsHandler.forbid(register, service);
//		OperateIdsHandler.delete(register, service);
//		
//		DialogDetailHandler.button(register, service, AccountDetail.class);
//		DialogUpdateHandler.button(register, service, AccountUpdate.class);
		//分配角色
		register.button("分配角色", "assign.do", ButtonEventType.DIALOG).ordinal(21);
		//重置密码
		register.button("重置密码", "resetpwd.do", ButtonEventType.DIALOG).ordinal(22);
		register.button("绑定", "resetpwd.do", ButtonEventType.DIALOG).title("绑定第三方的账户(如：QQ、微信、新浪等)。").ordinal(23);
//		OperateIdHandler.resume(register, service);
//		OperateIdHandler.forbid(register, service);
//		OperateIdHandler.delete(register, service);
		
		return service;
	}

	@Override
	protected Class<AccountItem> itemClass() {
		return AccountItem.class;
	}
}
